package net.minecraft.src;

import java.util.Random;

public class BlockSnow extends Block
{
    protected BlockSnow(int i, int j)
    {
        super(i, j, Material.snow);
        setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
        setTickOnLoad(true);
    }

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        int l = world.getBlockMetadata(i, j, k) & 7;
        if (l >= 3)
        {
            return AxisAlignedBB.getBoundingBoxFromPool((double)i + minX, (double)j + minY, (double)k + minZ, (double)i + maxX, (float)j + 0.5F, (double)k + maxZ);
        }
        else
        {
            return null;
        }
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }

    public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)
    {
        int l = iblockaccess.getBlockMetadata(i, j, k) & 7;
        float f = (float)(2 * (1 + l)) / 16F;
        setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    }

    public boolean canPlaceBlockAt(World world, int i, int j, int k)
    {
        int l = world.getBlockId(i, j - 1, k);
        if (l == 0 || l != Block.leaves.blockID && !Block.blocksList[l].isOpaqueCube())
        {
            return false;
        }
        else
        {
            return world.getBlockMaterial(i, j - 1, k).blocksMovement();
        }
    }

    public void onNeighborBlockChange(World world, int i, int j, int k, int l)
    {
        canSnowStay(world, i, j, k);
    }

    private boolean canSnowStay(World world, int i, int j, int k)
    {
        if (!canPlaceBlockAt(world, i, j, k))
        {
            world.setBlockWithNotify(i, j, k, 0);
            return false;
        }
        else
        {
            return true;
        }
    }

    public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
    {
    	dropBlockAsItem(world, i, j, k, l, 0);
        entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1);
    }

    public int idDropped(int i, Random random, int j)
    {
        return Item.snowball.shiftedIndex;
    }

    public int quantityDropped(Random random)
    {
        return 1;
    }

    public void updateTick(World world, int i, int j, int k, Random random)
    {
        if (world.getSavedLightValue(EnumSkyBlock.Block, i, j, k) > 11)
        {
            world.setBlockWithNotify(i, j, k, 0);
        }
    }

    public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)
    {
        if (l == 1)
        {
            return true;
        }
        else
        {
            return super.shouldSideBeRendered(iblockaccess, i, j, k, l);
        }
    }
}
